<template>
  <div>
    <h1>反馈管理</h1>
    <el-table
      :data="feedbackList"
      style="width: 100%">
      <el-table-column
        prop="feedbackId"
        label="id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="feedbackContent"
        label="反馈内容"
        width="180">
      </el-table-column>
      <el-table-column
        prop="pic"
        label="反馈图片"
        width="180">
        <template slot-scope="scope" >
          <img :src="scope.row.pic" width="100px" >
        </template>
      </el-table-column>
      <el-table-column
        prop="feedbackTypeId"
        label="反馈类型"
        width="80">
        <template slot-scope="scope" >
          <span v-if="scope.row.feedbackTypeId==1" >APP使用疑问</span>
          <span v-if="scope.row.feedbackTypeId==2" >投诉举报</span>
          <span v-if="scope.row.feedbackTypeId==3" >Bug反馈</span>
          <span v-if="scope.row.feedbackTypeId==4" >活动咨询</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="userId"
        label="反馈用户id"
        width="70">
      </el-table-column>
      <el-table-column
        prop="respond"
        label="是否回应"
        width="180">
        <template slot-scope="scope" >
          <span v-if="scope.row.respond==0" >未回应</span>
          <span v-if="scope.row.respond==1" >已回应</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="feedbackRespond"
        label="回应内容"
        width="180">
      </el-table-column>
      <el-table-column
        prop="adminId"
        label="管理员id"
        width="50">
      </el-table-column>
      <el-table-column
        label="操作"
        width="180">
        <template slot-scope="scope"  >
          <el-button v-if="scope.row.respond==0" type="primary" @click="openRespond(scope)">回应</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page.sync="pageNum"
      :page-sizes="[1, 2, 3, 4]"
      :page-size.sync="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="queryFeedback"
      @current-change="queryFeedback">
    </el-pagination>

    <el-dialog
      title="回应"
      :visible.sync="dialogVisible"
      width="30%">
      <el-input
        v-model="feedback.feedbackRespond"
        type="textarea"
        :rows="2"
        placeholder="请输入回应">
      </el-input>
      <el-button type="primary" @click="respond()">回应</el-button>
    </el-dialog>



  </div>
</template>
<script>
import {queryFeedback,respond} from '@/api/feedback'
export default {
  data(){
    return{
      feedback:{},
      pageNum:1,
      pageSize:4,
      total:0,
      feedbackList:[],
      dialogVisible:false,
      tabPosition: 'left'
    }
  },
  mounted() {
    this.queryFeedback()
  },
  methods:{
    openRespond(scope){
      this.dialogVisible=true
      this.feedback=scope.row
      this.feedback.adminId=1;
    },
    queryFeedback(){
      queryFeedback(this.pageNum,this.pageSize).then(res=>{
        if(res.data){
          this.feedbackList=res.data
          this.total=res.total
        }
      })
    },
    respond(){
      respond(this.feedback).then(res=>{
        console.log('feedback',res)
        alert(res.msg)
        this.feedback={}
        this.dialogVisible=false
        this.queryFeedback()
      })
    }

  }
}
</script>
<style>

</style>
